<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    session_start();
    if($_REQUEST['btnAddAuthor'])
    {
        $AuthorFirstName = $_REQUEST['txtAuthorFirstName'];
        $AuthorMiddleName = $_REQUEST['txtAuthorMiddleName'];
        $AuthorLastName = $_REQUEST['txtAuthorLastName'];
        
        //$AuthorMiddleName = ($AuthorMiddleName == '' ? NULL : $AuthorMiddleName);
        
        require '../lib/util.php';
        
        $sql = "CALL sp_AddAuthor ('".$AuthorFirstName."', '".$AuthorMiddleName."', '".$AuthorLastName."', 1)";
        $rs = executeSqlQuery($sql);
        $rowCount = mysql_affected_rows();
        
        closeDbConnection();
        
        if ($rs)
        {
            $_SESSION['InfoMsg'] = "New Author has added successfuly.";
            header("Location:../refAddAuthors.php");
        }
        else
        {
            $_SESSION['InfoMsg'] = "Error occured while adding new Author record.";
            header("Location:../refAddAuthors.php");            
        }
    }

?>
